package yxy.cherry.battle.module.affix.buff;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.affix.AffixFactory;
import yxy.cherry.battle.module.affix.Buff;
import yxy.cherry.battle.module.affix.BuffType;
import yxy.cherry.battle.module.record.stream.RecordStream_BFA;
import yxy.cherry.data.bean.skill;

import java.util.ArrayList;
import java.util.Map;

/**
 * 解除免死
 * 该技能和免死技能配套使用
 *
 * @ClassName Affix83RemoveAvoidKillShield
 * @Author jingtao-zheng
 * @Date 2022/8/30 17:04
 * @Version 1.0
 **/
@BuffType(Type = AffixFactory.BuffTypeEnum.解除免死)
public class Affix83RemoveAvoidKillShield extends Buff {

    public Affix83RemoveAvoidKillShield(Fighter source, Fighter target, skill skilldata, int[] params) {
        super(source, target, skilldata, params);
    }

    @Override
    public boolean exec(Fighter source, Fighter target) {
        Map<String, Buff> buffMap = source.getBuffMap();
        if (buffMap != null) {
            for (Map.Entry<String, Buff> buffEntry : buffMap.entrySet()) {
                String buffName = buffEntry.getValue().toString();
                if(buffName.equals(AffixFactory.BuffTypeEnum.免死.name())){
                    Affix61AvoidKillShield value = (Affix61AvoidKillShield) buffEntry.getValue();
                    boolean sx = value.isSX();
                    if(sx) {
                        Buff removeBuff = buffEntry.getValue();
                        ArrayList<Buff> buffList = new ArrayList<>();
                        buffList.add(removeBuff);
                        source.removeBuff(buffEntry.getValue());
                        getRecord().stream(new RecordStream_BFA(source, buffList)).record();
                        Battle.battleLogger(6, "免死：" + source.getName() + "移除了免死buff");
                    }
                }
            }
        }
        return true;
    }
}
